home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 3
/
Info_Mac_1994-01.iso
/
Development
/
General
/
GCC 1.37.1r15
/
Documents
/
Using GCC
< prev
Wrap
Text File
|
1993-01-14
|
5KB
|
97 lines
This GCC port has been designed to fit as smoothly as possible into the MPW
environment. Once GCC has been installed, you need only change the name of
the C compiler from "C" to "gC". All of the usual MPW include files and libraries
should work exactly the same as with MPW C; please let me know when they don't!
There are some known differences between GCC and MPW C:
* Some MPW C options are not implemented by GCC. See GCC.Help for the exact list
of what is available.
* The dump and load pragmas are not supported. Their presence will
not cause an error however.
* The preprocessor symbol __DUMP__ is always undefined.
* The preprocessor symbol __SEG__ cannot be used to set the segment.
* The preprocessor symbol "mpwgcc" is defined.
* The "comp" type is recognized and has code generated for it, but the
library routines are presently undefined.
* -sym options are just passed on to the MPW assembler, so SADE won't be that
useful with your C source code.
* Since GCC produces code that is processed by the MPW Assembler, any C symbols
that are the same as the names of 68xxx registers (d0, sp, caar, etc) must be
changed to something else. GCC will postpend a _ and issue a warning that this
is being done. If all of your program is being compiled by GCC, there shouldn't
be any problems, but if you mix MPW C and GCC code, then you will get linker
errors, and must modify your source code to use different symbols.
* A number of MPW bugs and sloppinesses are missing from GCC. Although this is
generally good, you may find that GCC complains about a number of situations that
MPW accepts silently (and sometimes incorrectly!).
* A common instance of this is when GCC complains about
void foo(short); ... void foo(x) short x; { ... }
This really is incorrect code, but MPW won't complain. GCC has been changed to
only issue a warning rather than an error in these cases, but you can expect to
see a lot of these.
ADDITIONAL FEATURES OF GCC
There are dozens of additional options and features in GCC, which I will only
summarize here. See the GCC.Help file and the GCC manual for full descriptions.
Also, the Commando interface is a convenient tour of all the command options.
Additional language constructs include statements and declarations inside of
expressions, named expression type, typeof, alignof, generalized lvalues, arrays of
variable length, nonconstant initializers, constructor expressions, function
inlining, and inline assembly code. Note that these nice new constructs are
not in MPW C, which will usually fail on them; the gC option -pedantic will
issue warnings when any of these appear in your code.
Additional GCC options include the ability to generate assembly language output,
optional optimization, a number of controls over warning messages, and a number of
controls over compilation technique.
Optimization in GCC is extremely good. On the 680x0, GCC will do excellent
register allocation, in addition to maximally exploiting addressing modes.
(A dramatic example is the inner loop of Mandelbrot calculation - GCC will use
all eight FPx registers for temporaries.) It does tend to favor code speed
over size. Some parts of the Mac interface are done awkwardly and/or slowly
(such as non-68881 SANE calls and pascal returns).
USING C++
The script gCPlus is an approximate implementation of MPW C++. It works by
running CFront with options set to produce text output, then invoking gC on
the result. MPW C++ and C++ in general are moving targets, so you're more likely
to run into incompatibilities and other problems (static constructors and
destructors are sometimes a hassle, for instance).
FURTHER READING
Both the compiler and preprocessor have their own manuals, which are in TeX
format. The installation document describes ways to get them into printed form.
The most useful parts are those describing the extra command options in detail
(since the manual was written for Unix GCC, many of the option names are different,
so watch out), and the sections describing GCC's extensions to C.
IF gC CRASHES
When the compiler runs into trouble, it will generally calls fancy_abort, which goes
into Macsbug. "g" usually gets you back to MPW safely. This should never occur for
the distributed compiler; please report any occurrences, ideally including the source
file and command options responsible. GCC may occasionally produce code that the
MPW Assembler will choke on; again, this shouldn't happen and should be reported
when it does. As a convenience when this happens, gC will leave the asm file
around rather than deleting it.
Known problems with GCC are listed in the file "BUGS". Fixes and/or suggestions
to solve any of these problems will be gratefully accepted and incorporated into
future releases of MPW GCC.